

export default class RunOrder{

    constructor(){
        this.nl=0;
        this.register='';
        this.ni='';
    }
    /**
     * 111 111 111 1  有条件跳转
     * 111 111 111 0  无条件跳转
     * 111 111 111 2  判断
     * 111 111 111 3  输入
     * 111 111 111 4  输出
     *
     */

    run(fileId,squareId,rowId,dataThis){
        let _this=this;
        if (this.nl>dataThis.list.length){
            let row=dataThis.list[this.nl];
            let a1,a2,a3;
            for(let i=0;i<3;i++){

            }
            if(row.find(3)===null ){
                if(row.find(2)==null){
                    _this. _run(fileId,squareId,row.find(1))
                }else {
                    _this. _run(fileId,row.find(2),row.find(1))
                }


            }else {
                _this._run(row.find(3),row.find(2),row.find(1))
            }
            if(row.isValue(4,"")){  //无条件跳转
                _this. _run(a1,a2,a3)
            }
            if(row.isValue(4,1)){ //有条件跳转
                if(_this.register===true){
                    _this. _run(a1,a2,a3)
                }else {
                    _this. _run(a1,a2,this.nl++)
                }

            }
            if(row.isValue(4,2)){
                _this.ni=a3;
                _this.pack.find(fileId,a1,a2,_this._if.bind(this));
                _this. _run(fileId,squareId,this.nl++)
            }
            if(row.isValue(4,3)){
                _this.ni=a3;
                _this.pack.find(fileId,a1,a2,_this._in.bind(this));
                _this. _run(fileId,squareId,this.nl++)
            }
            if(row.isValue(4,4)){
                _this.ni=a3;
                _this.pack.find(fileId,a1,a2 ,_this._out.bind(this));
                _this. _run(fileId,squareId,this.nl++)
            }
        }
    }
    _in(fileId,squareId,rowId,dataThis){
          this.register=dataThis.find(this.in)
    }
    _out(fileId,squareId,rowId,dataThis){
         dataThis.save(this.in, this.register)
    }
    _if(fileId,squareId,rowId,dataThis){
          if( dataThis.isValue(this.in, this.register)) {
              this.register=true;
          }else {
              this.register=false;
          }

    }
    _run(fileId,squareId,rowId,dataThis){
        this.nl=rowId
        this.pack.findData(fileId,squareId,null,_this.run.bind(this))
    }
}